//
//  DKButton.h
//  ButtonTest
//
//  Created by Alex on 15-2-11.
//  Copyright (c) 2015年 Alex. All rights reserved.
//

#import <UIKit/UIKit.h>

@class DKButton;
//----------------------------------------------------
//渲染颜色的枚举
typedef enum
{
    DKButtonRenderingModeAlwaysOriginal,//使用原始颜色渲染
    DKButtonRenderingModeAlwaysTemplate//使用tintColor渲染
}DKButtonRenderingMode;

//----------------------------------------------------
//设置按钮颜色的枚举
typedef enum
{
    DKButtonStateNormal,//按钮普通状态
    DKButtonStatePressed,//按钮按下状态
    DKButtonStateLoading//按钮loading状态
}DKButtonState;

//----------------------------------------------------
//设置响应事件的触发时机的枚举
typedef enum
{
    DKButtonEventPressedBegan,//开始按时
   // DKButtonEventPressing,//按的时候
    DKButtonEventPressedEnd//松开按钮时
}DKButtonEvent;

//----------------------------------------------------
//图片与文字的先后顺序
typedef enum
{
    DKButtonImagePositionAtBegan,//图片在前面
    DKButtonImagePositionAtEnd,//图片在后面
}DKButtonImagePosition;

//----------------------------------------------------
//点击事件的代码块定义
typedef void(^DKButtonEventBlock)(DKButton* sender);


//----------------------------------------------------
@interface DKButton : UIView
{
    UIColor* normalColor;//普通的颜色(默认灰色)
    UIColor* pressColor;//按下后的颜色
    UIColor* loadingColor;//加载时的颜色
    
    
    //点击事件(三种状态)
    __weak id targetBegan;
    SEL selectBegan;
    DKButtonEventBlock blockBegan;
    
    __weak id targetPressing;
    SEL selectPressing;
    DKButtonEventBlock blockPressing;
    
    __weak id targetEnd;
    SEL selectEnd;
    DKButtonEventBlock blockEnd;
}
@property CGFloat pressAlpha;//没有设置按下颜色时按下会变透明度(默认为0.5)(如果设置来pressColor，则此属性无效)

//图片部分
@property UIImageView* buttonImage;//图片按钮
@property (nonatomic) UIColor* imageTintColor;//图片在纯色渲染模式下用的颜色(默认白色)
@property (nonatomic) DKButtonRenderingMode imageRenderingMode;//图片的渲染模式(默认纯色)
@property (nonatomic) UIImage* image;//图片(默认为空)
@property (nonatomic) CGSize imageSize;//图片尺寸

//文字部分
@property UILabel* buttonTitle;//文字按钮
@property (nonatomic) UIColor* textColor;//文字颜色(默认白色)
@property (nonatomic) NSString* text;//文字
@property (nonatomic) UIFont* font;//文字的字体

//右侧View(多为箭头)
@property (nonatomic)UIView* accessoryView;
@property (nonatomic)CGSize accessorySize;
@property (nonatomic)CGFloat accessoryRightGap;


//文字与图片间的间距
@property (nonatomic) CGFloat imageTitleGap;

//图片与文字的顺序
@property (nonatomic) DKButtonImagePosition imagePosition;//(默认图片在前)

//进度条按钮
@property (nonatomic) UIActivityIndicatorView* buttonLoading;
-(void)startLoading;//开始加载loading动画
-(void)endLoading;//结束加载loading动画


//设置普通、按下和加载时的颜色
-(void)setColor:(UIColor*)color ForState:(DKButtonState)state;

//设置点击事件
-(void)addTarget:(id)target Select:(SEL)select ForEvent:(DKButtonEvent)event;
-(void)addBlock:(DKButtonEventBlock)block ForEvent:(DKButtonEvent)event;

//移除点击事件
-(void)removeEvent:(DKButtonEvent)event;
@end
